package com.lagou.controller;

import com.lagou.manager.ZkManager;
import com.lagou.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/sayHello")
public class UserController {

    @Autowired
    private ZkManager zkManager;

    @GetMapping
    public String sayHello() {
        for (Map.Entry<Integer, IUserService> entry : zkManager.serviceMap.entrySet()) {
            String result = entry.getValue().sayHello("hello!");
            System.out.println(result);
        }

        return "success";
    }
}
